//
//  PhotoMessageViewController.m
//  跨界收
//
//  Created by Allen on 2018/11/20.
//  Copyright © 2018年 gztx. All rights reserved.
//

#import "PhotoMessageViewController.h"
#import "PhotoMessageTableViewCell.h"
#import "JiBenXinXiView.h"
#import "SendIDCardViewController.h"
#import "SendBusinessLicenseViewController.h"
#import "SendOpneningPermitViewController.h"
#import "SendDoorwayAndInteriorPhotosViewController.h"

@interface PhotoMessageViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableview;
@property (nonatomic, strong) NSArray *sectionArray;
@property (nonatomic, strong) NSArray *titleArray;

@end

@implementation PhotoMessageViewController


- (void)initData
{
    _sectionArray = @[@"法人身份证"];
    _titleArray = @[@"法人身份证",@"营业执照",@"开户许可证",@"门口照及内景照",];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"照片资料";
    [self initData];
    self.tableview.delegate = self;
    self.tableview.dataSource = self;
    self.tableview.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    [self.tableview registerNib:[UINib nibWithNibName:@"PhotoMessageTableViewCell" bundle:nil] forCellReuseIdentifier:@"cell"];
    UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 80)];
    header.backgroundColor = [UIColor whiteColor];
    JiBenXinXiView *view = [JiBenXinXiView shareInstance];
    for (id label in view.fourView.subviews) {
        if ([label isKindOfClass:[UILabel class]]) {
            UILabel *oneLabel = (UILabel *)label;
            oneLabel.textColor = [UIColor cz_colorWithHex:0x239fdb];
        }
    }
    view.frame = CGRectMake(0, 0, SCREEN_WIDTH, 80);
    [header addSubview:view];
    self.tableview.tableHeaderView = header;
    // Do any additional setup after loading the view from its nib.
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *headerview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 30)];
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, 300, 30)];
    label.text = _sectionArray[section];
    label.textColor = [UIColor lightGrayColor];
    label.font = [UIFont systemFontOfSize:16];
    [headerview addSubview:label];
    return headerview;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 30;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return _sectionArray.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _titleArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *indetifier = @"cell";
    PhotoMessageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indetifier];
    if (!cell) {
        cell = [[PhotoMessageTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indetifier];;
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.titleLabel.text = _titleArray[indexPath.row];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    switch (indexPath.section) {
        case 0:
        {
            switch (indexPath.row) {
                case 0:
                {
                    SendIDCardViewController *sendVC = [[SendIDCardViewController alloc] initWithNibName:@"SendIDCardViewController" bundle:nil];
                    [self.navigationController pushViewController:sendVC animated:YES];
                }
                    break;
                case 1:
                {
                    SendBusinessLicenseViewController *sendVC = [[SendBusinessLicenseViewController alloc] initWithNibName:@"SendBusinessLicenseViewController" bundle:nil];
                    [self.navigationController pushViewController:sendVC animated:YES];
                }
                    break;
                case 2:
                {
                    SendOpneningPermitViewController *sendVC = [[SendOpneningPermitViewController alloc] initWithNibName:@"SendOpneningPermitViewController" bundle:nil];
                    [self.navigationController pushViewController:sendVC animated:YES];
                }
                    break;
                case 3:
                {
                    SendDoorwayAndInteriorPhotosViewController *sendVC = [[SendDoorwayAndInteriorPhotosViewController alloc] initWithNibName:@"SendDoorwayAndInteriorPhotosViewController" bundle:nil];
                    [self.navigationController pushViewController:sendVC animated:YES];
                }
                    break;
                    
                default:
                    break;
            }
        }
            break;
        default:
            break;
    }
}
@end
